package com.itbaizhan.springsecuritydemo.handler;

import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
//自定义退出登录器  实现LogoutSuccessHandler接口
//成功退出登录后，不只是清除认证(.clearAuthentication(true))与删除HttpSession对象（.invalidateHttpSession(true)） 还可惊人做一些其它处理
public class MyLogoutSuccessHandler implements LogoutSuccessHandler {
    @Override
    public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {

        System.out.println("清除一些数据");
        response.sendRedirect("/login.html");

    }
}
